<?php 
$customerid=Mage::getSingleton('customer/session')->getCustomerId();
$isPartner= Mage::getModel('marketplaceprofile/marketplaceprofile')->isPartner($customerid);
if($isPartner==1){?>
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/global.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/jquery.jqplot.min.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/webkul-image-slider.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/shCoreDefault.min.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->getSkinUrl('Customerpartner/css/shThemejqPlot.min.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jquery.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jquery.jqplot.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shCore.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shBrushJScript.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/shBrushXml.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.logAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasTextRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisLabelRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisTickRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.dateAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.categoryAxisRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.barRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasTextRenderer.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->getSkinUrl('Customerpartner/js/jqplot.canvasAxisLabelRenderer.min.js'); ?>" type="text/javascript"></script>
<style>
div.example-plot { height: 400px;width: 650px;}
.ctable{
 border-spacing: 0;
    empty-cells: show;
    font-size: 100%;
}
#divid {
    border-bottom: 1px solid #F5F5F5;
    border-left: 1px solid #F5F5F5;
    border-right: 1px solid #F5F5F5;
    display: block;
   
    width: auto;
}
</style>
<?php		
	$write = Mage::getSingleton('core/resource')->getConnection('core_write');
	$read = Mage::getSingleton('core/resource')->getConnection('core_read');
	$products = $this->getProducts();
	$readresult=Mage::getModel('marketplacepartner/Productsales')->getOrderdetails($customerid);
	$customerPartner = Mage::getModel('marketplacepartner/productsales');
	$getDateDetail = $customerPartner->getDateDetail();
	$cur_symbol=Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();

	/*$write = Mage::getSingleton('core/resource')->getConnection('core_write');
	$mysqlprefix = Mage::getConfig()->getTablePrefix();//code for mysql prefix
	
	//TO DO
	$sqlselect="SELECT mageproductid FROM ".$mysqlprefix."marketplacepartner_entity_data";
	$sqlselect1=$write->query($sqlselect);
	$sqlselectrow=$sqlselect1->fetchAll();*/
?>
<div class="prdouctbackground">
	<div class="maindash">
		<h4 class="textcolor"><?php echo Mage::helper('marketplacepartner')->__('Dashboard') ?></h4>
		<button style="float:right;background: none repeat scroll 0 0 #E8CFBB;"   class="askque"><span><?php echo Mage::helper('marketplacepartner')->__('Ask Question to Admin') ?></span></button><br>
		<div class="salesmonth">
			 <div class="todaydash"><?php echo  $cur_symbol.$getDateDetail[day];?>&nbsp;<span class="textcolordash">&nbsp;<?php echo Mage::helper('marketplacepartner')->__('Today') ?></span>
			 </div>
			 <div class="weekdash"><?php echo $cur_symbol.$getDateDetail[week]; ?>&nbsp;<span class="textcolordash">&nbsp;<?php echo Mage::helper('marketplacepartner')->__('Week') ?></span>
			 </div>
			 <div class="monthdash"><?php echo $cur_symbol.$getDateDetail[month]; ?>
				&nbsp;
				<span class="textcolordash"><?php echo Mage::helper('marketplacepartner')->__('Month') ?></span>
			 </div>
		</div>
		<div class="salesemail"></div>
		<div class="orderdproduct">
			<div class="tablepostioneditdash ctable">
				<div class="headingbg"><?php echo Mage::helper('marketplacepartner')->__('Latest Order') ?> </div>
				<div id="divid">
					<?php
						$m=0;
						foreach($readresult as $res){
							$order = Mage::getModel('sales/order')->load($res['mageorderid']);
							$status=$order->getStatus();
							$name=$order->getCustomerName();
							if($res['mageorderid']>0){?>
								<div id="divid">
									<div class="tdpadfirsteditheadingdash" style="float:left;width:206px;">
										<label for="name" class="rightgapeditheadedit">
											<?php if($status=='pending') {?>
												<div class="status" style="background-color:orange"><?php echo strtoupper($status); ?> </div>
											<?php }?>
											<?php if($status=='canceled') {?>
												<div class="status" style="background-color:red"><?php echo strtoupper($status); ?> </div>
											<?php }?>
											<?php if($status=='complete') {?>
												<div class="status" style="background-color:green"><?php echo strtoupper($status); ?> </div>
											<?php }?>
											<?php if($status=='processing') {?>
												<div class="status" style="background-color:blue"><?php echo strtoupper($status); ?> </div>
											<?php }?>
											<p style="margin: 0 0 10px 6px;"><?php echo "<br>".$res['cleared_at']; ?></p> 
										</label> 
									</div>
									<div class="tdpadfirsteditheadingdash" style="float:left; width:206px;">
										<label for="name" class="rightgapeditheadedit">
											<div class="textcolordashdiv">Order #<?php echo $res['magerealorderid']; ?></div>
											<div class="dd">By<?php  echo " ".$name; ?><br/>
											<?php
											  $pname=explode(',',$res['mageproname']);
											  $pid=explode(',',$res['mageproid']);
												for($p=0;$p<=count($pid);$p++){
												if($pname[$p]){
														echo "<p style='color:silver;float:left;'>".$pname[$p]."&nbsp;</p>"; $proid[$m]=$pid[$p];
														}
													
												}?>
											</div> 
										</label> 
									</div>
									<div class="tdpadfirsteditheadingdash" style="float:right;width:206px;">
										<label for="name" class="rightgapeditheadprice">$<?php echo $res['actualparterprocost'];?> </label> 
									</div>
								</div><div style="clear:both;"></div>
					<?php }
						} 
						?>	
								
				</div>
							
			</div>		
		</div>
		<div class="review">
			<h4 colspan="2" class="headingbg"><?php echo Mage::helper('marketplacepartner')->__('Latest Comments & Reviews') ?></h4>
			<?php 
			   /* foreach($sqlselectrow as $product)
				{*/
					/*$productId=$product['mageproductid'];		
					$reviews = Mage::getModel('review/review')
							    ->getResourceCollection()
								->addStoreFilter(Mage::app()->getStore()->getId())
								->addEntityFilter('product', $productId)
								->setDateOrder()
								->addRateVotes();
					foreach($reviews as $review){
					$allpro=Mage::getModel('catalog/product')->load($review->getEntityPkValue());
					$productcity=Mage::getModel('catalog/product')->load($allpro['entity_id']);	*/
			
				$feeds = Mage::getModel('marketplacepartner/feedback')->getCollection()
							->addFieldToFilter('proownerid',array('eq'=> Mage::getSingleton('customer/session')->getId()));
						foreach($feeds as $feed){
				?>
								<div style=" border-bottom: 1px solid #CCCCCC;clear: both;min-height: 80px;padding: 10px;">
									<div class="feedback">
										<div class="price">
											<h2  class="rightgapeditheadedit" style="margin: 0 0 10px 6px;float: left;font-size:13px;"><?php echo Mage::helper('marketplacepartner')->__('Price') ?> :</h2>
											<div class="ratingslider-box">
												<div class="rating" style="width:<?php echo ceil($feed->getfeedprice());?>%;"></div>
											</div>
											<div style="clear:both;"></div>
										</div>
										<div class="value">
											<h2 class="rightgapeditheadedit" style="margin: 0 0 10px 6px;float: left;font-size:13px;"><?php echo Mage::helper('marketplacepartner')->__('Value') ?> :</h2>
											<div class="ratingslider-box" >
												<div class="rating" style="width:<?php echo ceil($feed->getfeedvalue());?>%;"></div>
											</div>
											<div style="clear:both;"></div>
										</div>
										<div class="quality">
											<h2 class="rightgapeditheadedit" style="margin: 0 0 10px 6px;float: left;font-size:13px;"><?php echo Mage::helper('marketplacepartner')->__('Quality') ?> :</h2>
											<div class="ratingslider-box">
												<div class="rating" style="width:<?php echo ceil($feed->getfeedquality());?>%;"></div>
											</div>
											<div style="clear:both;"></div>
										</div>
									</div>
									<div class="buyer" style="float: left; width: 150px;">
										<?php echo Mage::helper('marketplacepartner')->__('FeedBack By') ?> 
										<span><br>
											<?php 
												echo $feedcustomer = Mage::getModel('customer/customer')->load($feed->getuserid())->getName(); 
											?>
										</span>
									</div>
									<div class="date"  style="float: left; width: 150px;"><?php echo Mage::helper('marketplacepartner')->__('Date') ?> <span><br><?php echo $feed->getcreatedat(); ?></span></div>
									<div class="RATING"><span title="" class="icon icon-fbk-pos hastip tooltipsy-init"></span></div>
									<div class="comment" style="width:500px;"><?php echo $feed->getfeedreview(); ?> </div>
								</div>		
		 			 <?php  }
				//} ?>		
		</div>
		<br>
		<div class="example-plot" id="chart2"></div>
	</div>
</div>
<div id="ask-data">
	<div class="modal-header">
		<h3><?php echo Mage::helper('marketplacepartner')->__('Ask Question to Admin') ?>..</h3>
		<span  class="wk-close" >x</span>
		<span  style="clear:both;" ></span>
	</div>
	<form id="ask-form" method="post" >
		<span class="label"><?php echo Mage::helper('marketplacepartner')->__('Subject') ?> :</span><input type="text" name="subject" class="querysubject"/>
		<span class="label"> <?php echo Mage::helper('marketplacepartner')->__('Ask') ?> :</span><textarea  name="ask" class="queryquestion"></textarea>
		<input type="hidden" name="seller-id" value="<?php echo Mage::getSingleton('customer/session')->getCustomerId();?>"/>
		<?php
		  /*require_once('recaptchalib.php');			
		  $publickey = Mage::getStoreConfig('partners/partners_options/recaptchapublic'); // you got this from the signup page
		  echo recaptcha_get_html($publickey); */
		?>
		<div class="modal-footer">
			<span class="error"></span>
			<input type="reset" value="<?php echo Mage::helper('marketplacepartner')->__('Reset') ?>" id="resetbtn"/>
			<input type="button" value="<?php echo Mage::helper('marketplacepartner')->__('Ask') ?>" id="askbtn"/>
			<span style="clear:both;"></span>
		</div>
	</form>
</div>
<script class="code" type="text/javascript" language="javascript">
jQuery.noConflict();
jQuery(document).ready(function(){   
     var data=JSON.parse('<?php echo Mage::getModel('marketplacepartner/Productsales')->getMonthlysale($customerid)?>');
	var line2 = [['1/1/<?php echo date('Y');?>',parseInt(data[1])], 
	             ['2/1/<?php echo date('Y');?>',parseInt(data[2])], 
				 ['3/1/<?php echo date('Y');?>',parseInt(data[3])], 
				 ['4/1/<?php echo date('Y');?>',parseInt(data[4])], 
				 ['5/1/<?php echo date('Y');?>',parseInt(data[5])], 
				 ['6/1/<?php echo date('Y');?>',parseInt(data[6])], 
				 ['7/1/<?php echo date('Y');?>',parseInt(data[7])], 
				 ['8/1/<?php echo date('Y');?>',parseInt(data[8])], 
				 ['9/1/<?php echo date('Y');?>',parseInt(data[9])], 
				 ['10/1/<?php echo date('Y');?>',parseInt(data[10])], 
				 ['11/1/<?php echo date('Y');?>',parseInt(data[11])], 
				 ['12/1/<?php echo date('Y');?>',parseInt(data[12])]
				];

    var plot2 = jQuery.jqplot('chart2', [line2], {
      axes: {
        xaxis: {
          renderer: jQuery.jqplot.DateAxisRenderer,
          label: "<?php echo Mage::helper('marketplacepartner')->__('Month')?>",
          labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
          tickRenderer: jQuery.jqplot.CanvasAxisTickRenderer,
          tickOptions: {angle: 30}
        },
        yaxis: {
          label: "<?php echo Mage::helper('marketplacepartner')->__('Money')?>",
          labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer
        }
      }
    });
    jQuery('.wrapper').append(jQuery('#ask-data'));
		jQuery('.askque').click(function(){
			jQuery('#ask-form input,#ask-form textarea').removeClass('error-border');
			jQuery('.page').css('opacity','0.4');
			jQuery('#ask-data').show();
		});
		jQuery('.wk-close').click(function(){
			jQuery('.page').css('opacity','1');
			jQuery('#resetbtn').trigger('click');
			jQuery('#ask-data').hide();
		});
		jQuery('#askbtn').click(function(){
				var f=0;
				jQuery('#ask-form input,#ask-form textarea').each(function(){
					if(jQuery(this).val()==''){
						jQuery(this).addClass('error-border');
						f++;
					}
				});
				if(f>0){
					jQuery('#ask-form .error').text("<?php echo Mage::helper('marketplacepartner')->__('Fill all the fields') ?>").slideDown('slow').delay(2000).slideUp('slow');
				}else{	
					jQuery('#ask-data').addClass('mail-procss');
					jQuery.ajax({
						url:'<?php echo Mage::getBaseUrl();?>marketplacepartner/partnerproducts/askquestion',
						data:jQuery('#ask-form').serialize(),
						type:'post',
						dataType:'json',
						success:function(d){
							jQuery('#ask-data').removeClass('mail-procss')
								alert("<?php echo Mage::helper('marketplacepartner')->__('Mail Send') ?>");
								jQuery('.wk-close,#resetbtn').trigger('click'); 
						}
					});
			}	
		});	
		
});
</script>
<div class="button-set buttonarea">
	<p class="headingbackindex">
		<a href="javascript:;" onclick="javascript: window.history.back();" class="left">&laquo; <?php echo Mage::helper('marketplacepartner')->__('Back') ?></a>
	</p>
</div>
<?php }else{
	echo Mage::helper('marketplacepartner')->__("<h2 style='color:#ff0000;font-weight:600'>FOR BECOME SELLER CONTACT TO ADMIN..</h2>");
}?>